
export function getItem(key) {
    return JSON.parse(localStorage.getItem(key))
}

export function setItem(key,value){
    localStorage.setItem(key,JSON.stringify(value))
}

export function thumbnail(name){
    const i = name.lastIndexOf('.');
    const type = ['webp', 'bmp', 'pcx', 'tif', 'gif', 'jpeg', 'jpg', 'tga', 'exif', 'fpx', 'svg', 'psd', 'cdr', 'pcd', 'dxf', 'ufo', 'eps', 'ai', 'png', 'hdri', 'raw', 'wmf', 'flic', 'emf', 'ico', 'avif', 'apng'];
    const ext = name.substr(i + 1);
    for(const i in type){
        if (ext.toLowerCase()===type[i]){
            return '/img/picture_type.svg'
        }
    }
    return '/img/unknown_type.svg'
}

export function getView(type){
    const pic = ['webp', 'bmp', 'pcx', 'tif', 'gif', 'jpeg', 'jpg', 'tga', 'exif', 'fpx', 'svg', 'psd', 'cdr', 'pcd', 'dxf', 'ufo', 'eps', 'ai', 'png', 'hdri', 'raw', 'wmf', 'flic', 'emf', 'ico', 'avif', 'apng'];
    var lType=type.toLowerCase()
    for(const i in pic){
        if (lType===pic[i]){
            return '/img/picture_type.svg'
        }
    }
    if(lType==='doc'||lType==='docx')
        return '/img/word_type.svg'
    if(lType==='xls'||lType==='xlsx')
        return '/img/excel_type.svg'
    if(lType==='ppt'||lType==='pptx')
        return '/img/ppt_type.svg'
    if(lType==='zip'||lType==='rar'||lType==='7z'||lType==='gz'||lType==='tar')
        return '/img/zip_type.svg'
    if(lType==='pdf')
        return '/img/pdf_type.svg'
    return '/img/unknown_type.svg'
}
